Developer Documentation

QuickTime 4 API Documentation

Wired Movies and Sprites

| Previous | Chapter Contents | Chapter Top | Next |

Creating the Movie, Sprite Track, and Media

Listing 3-1 shows a code fragment from the sample code QTWiredSprites.c . This sample code, which is available in Appendix  , illustrates how you can create a new movie file that calls a sample code function, AddSpriteTrackToMovie , which is responsible for creating a sprite track and adding it to the movie.

Listing 1 Creating a sprite track movie

// Create a QuickTime movie containing a wired sprites track
.
.
.
    // create a new movie file and set its controller type
    // ask the user for the name of the new movie file
    StandardPutFile("\pSprite movie file name:", "\pSprite.mov",
                    &myReply);
    if (!myReply.sfGood)
        goto bail;

    // create a movie file for the destination movie
    myErr = CreateMovieFile(&myReply.sfFile, FOUR_CHAR_CODE('TVOD'), 0,
                myFlags, &myResRefNum, &myMovie);
    if (myErr != noErr)
        goto bail;
    
    // select the "no controller" movie controller
    myType = EndianU32_NtoB(myType);
    SetUserDataItem(GetMovieUserData(myMovie), &myType, sizeof(myType),
                        kUserDataMovieControllerType, 1);

The following code fragment from AddSpriteTrackToMovie ( Listing 3-2 ) creates a new track and new media, and creates an empty key frame sample. AddSpriteTrackToMovie then calls BeginMediaEdits ( Listing 3-4 ) to prepare to add samples to the track's media.

Listing 2 Creating a track and media

// create the sprite track and media
    
    myTrack = NewMovieTrack(myMovie, ((long)kSpriteTrackWidth << 16),
                        ((long)kSpriteTrackHeight << 16), kNoVolume);
    myMedia = NewTrackMedia(myTrack, SpriteMediaType,
                            kSpriteMediaTimeScale, NULL, 0);

    // create a new, empty key frame sample
    myErr = QTNewAtomContainer(&mySample);
    if (myErr != noErr)
        goto bail;

    myKeyColor.red = 0xffff;                        // white
    myKeyColor.green = 0xffff;
    myKeyColor.blue = 0xffff;


© 1999 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |